﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition.SrgsGrammar;
using System.Speech.Recognition;

namespace VoiceRecognition.Work.Code
{
    public class RecoMan
    {
        private List<VoiceRecognition.Work.Code.ASR> _VOCALS;

        public int EngineCount { get{ return _VOCALS.Count;} }

        public RecoMan()
        {
            _VOCALS = new List<ASR>();
            LoadGrFiles();
        }

        private void LoadGrFiles()
        {
            String[] files = null;
            String Dir = System.IO.Directory.GetCurrentDirectory() + "\\Work\\Grammar\\";

           files =  System.IO.Directory.GetFiles(Dir,".grxml");
           ASR engine = null;
           foreach (var st in files)
           {
               engine = new ASR();
               //Création d'un document de la norme SRGS à partir du fichier grxml
               SrgsDocument xmlGrammar = new SrgsDocument(Dir + st);
               //Création d'une grammaire depuis le fichier de grammaire
               Grammar grammar = new Grammar(xmlGrammar);
               engine.ASREngine.LoadGrammar(grammar);

               engine.CurrentGrammar = st;

               _VOCALS.Add(engine);
           }
        }
    }
}
